# from rest_framework import status
# from rest_framework.response import Response
# from rest_framework.views import APIView
# from django_redis import get_redis_connection
#
# # 日志调用
# import logging
# logger = logging.getLogger("django")
#
# class HomeAPIView(APIView):
#     def get(self,request):
#         # 测试日志功能
#         # logger.debug("debug信息")
#         # logger.info("info信息")
#         # print("hello")
#         redis = get_redis_connection('sms_code')
#         brother = redis.lrange('brother', 0, -1)
#         # brother = ['关于','路和']
#         return Response(brother, status=status.HTTP_200_OK)

import luffycityapi.utils.constants as constants
from rest_framework.generics import ListAPIView
from .models import Nav, Banner
from .serializers import NavModelSerializer, BannerModelSerializer
from luffycityapi.utils.views import CacheListAPIView



class NavHeaderListAPIView(CacheListAPIView):
    """顶部view导航"""
    queryset = Nav.objects.filter(position=constants.NAV_HEADER_POSITION, is_show=True, is_deleted=False).order_by('order','-id')[:constants.NAV_HEADER_SIZE]
    serializer_class = NavModelSerializer


class NavFooterListAPIView(CacheListAPIView):
    """底部view导航"""
    queryset = Nav.objects.filter(position=constants.NAV_FOOTER_POSITION, is_show=True, is_deleted=False).order_by('order','-id')[:constants.NAV_FOOTER_SIZE]
    serializer_class = NavModelSerializer

class BannerListAPIView(CacheListAPIView):
    """轮播广告"""
    queryset = Banner.objects.filter(is_show=True, is_deleted=False).order_by('order','-id')[:constants.BANNER_SIZE]
    serializer_class = BannerModelSerializer